package com.example.springLearning.part1.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/spring/part1")
public class ComponentScanController {

    /**
     * 該controller包位置与启动类不在同一个包下，bean注册时，不会扫描到该controller bean，在启动类上加上注解componentScans注解，
     * 添加该位置启动时添加bean
     * @ComponentScans(value = {@ComponentScan("controller.componentScan.controller"), @ComponentScan("com.example.controller"), @ComponentScan("com.example.springLearning.*")})
     * @SpringBootApplication(scanBasePackages = {"controller.componentScan.controller", "com.example.controller", "com.example.springLearning", "com.example.demo"})
     * @return
     */
    @ResponseBody
    @GetMapping("/componentScan")
    public String helloWorld() {

        return "componentScans!";
    }
}
